package com.caregiver.watch.business.care.model.vo;

import com.caregiver.watch.business.data.model.po.HealthBaseData;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

/**
 * @Description: 活动数据
 * @Author 疆戟
 * @Date 2025/10/21 22:43
 * @Version 1.0
 */
@Data
@Schema(description = "活动数据")
public class ActivityDataVo {

    @Schema(description = "运动时长(分钟)")
    private Integer runTime;
    /**
     * 消耗的卡路里
     */
    @Schema(description = "消耗的卡路里")
    private BigDecimal totalCalorie;

    @Schema(description = "步数")
    private Integer totalStep;

    @Schema(description = "站立时长")
    private Integer standTime;


    /**
     * 活动详情数据
     */
    @Schema(description = "活动详情数据")
    private List<ActivityDataDetailVo> detailVos;


    @Schema(description = "步数列表")
    private List<StepsStatistics> stepsList;

    @Schema(description = "卡路里列表")
    private List<CalorieStatistics> calorieList;

    @Schema(description = "活动时长列表")
    private List<ActivityDurationStatistics> durationList;

    @Schema(description = "站立时长列表")
    private List<StandTimeStatistics> standTimeList;

    public static ActivityDataVo build(HealthBaseData healthBaseData) {
        ActivityDataVo activityDataVo = new ActivityDataVo();
        if (Objects.isNull(healthBaseData)) {
            return activityDataVo;
        }
        activityDataVo.setTotalCalorie(healthBaseData.getCalorie());
        activityDataVo.setTotalStep(healthBaseData.getStepCount());
        activityDataVo.setStandTime(healthBaseData.getStandTime());
        activityDataVo.setRunTime(healthBaseData.getActivityDuration());
        return activityDataVo;
    }


    /**
     * 步数统计
     */
    @Data
    @Schema(description = "步数统计")
    public static class StepsStatistics {
        /**
         * 步数
         */
        @Schema(description = "步数")
        private Integer steps;
        /**
         * 时间（小时）
         */
        @Schema(description = "时间（小时）")
        private Integer time;

        public static StepsStatistics build(int steps, Integer key) {
            StepsStatistics stepsStatistics = new StepsStatistics();
            stepsStatistics.steps = steps;
            stepsStatistics.time = key;
            return stepsStatistics;
        }
    }

    @Data
    @Schema(description = "卡路里统计")
    public static class CalorieStatistics {
        /**
         * 卡路里
         */
        @Schema(description = "卡路里")
        private BigDecimal calorie;

        /**
         * 时间（小时）
         */
        @Schema(description = "时间（小时）")
        private Integer time;

        public static CalorieStatistics build(BigDecimal calories, Integer key) {
            CalorieStatistics calorieStatistics = new CalorieStatistics();
            calorieStatistics.calorie = calories;
            calorieStatistics.time = key;
            return calorieStatistics;
        }
    }

    @Data
    @Schema(description = "活动时长统计")
    public static class ActivityDurationStatistics {
        /**
         * 活动时长
         */
        @Schema(description = "活动时长")
        private Integer duration;
        /**
         * 时间（小时）
         */
        @Schema(description = "时间（小时）")
        private Integer time;

        public static ActivityDurationStatistics build(Integer duration, Integer time) {
            ActivityDurationStatistics activityDurationStatistics = new ActivityDurationStatistics();
            activityDurationStatistics.duration = duration;
            activityDurationStatistics.time = time;
            return activityDurationStatistics;
        }
    }

    @Data
    @Schema(description = "站立时长统计")
    public static class StandTimeStatistics {
        /**
         * 站立时长
         */
        @Schema(description = "站立时长")
        private Integer standTime;
        /**
         * 时间（小时）
         */
        @Schema(description = "时间（小时）")
        private Integer time;

        public static StandTimeStatistics build(Integer standTime, Integer time) {
            StandTimeStatistics standTimeStatistics = new StandTimeStatistics();
            standTimeStatistics.standTime = standTime;
            standTimeStatistics.time = time;
            return standTimeStatistics;
        }
    }
}
